package com.gxa.personal.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gxa.common.base.RespResult;
import com.gxa.personal.entity.MyReminder;
import com.gxa.personal.mapper.MyReminderMapper;
import com.gxa.personal.service.MyReminderService;
import org.springframework.stereotype.Service;

/**
 * Create with IntelliJ IDEA.
 * Description:
 * User: ZY
 * Date: 2023-04-10
 * Time: 16:25
 */
@Service
public class MyReminderServiceImpl implements MyReminderService {

    MyReminderMapper myReminderMapper;




    @Override
    public RespResult findAllReminder() {
        LambdaQueryWrapper<MyReminder> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.orderByDesc(MyReminder::getReminderTime);

        return RespResult.success(myReminderMapper.selectList(queryWrapper));
    }



    @Override
    public RespResult add(MyReminder myReminder) {
        int insert = myReminderMapper.insert(myReminder);
        if (insert>0){
            return RespResult.success();
        }
        return RespResult.error("添加提醒失败");
    }


    @Override
    public RespResult cancel(Integer myReminderId) {
        int del = myReminderMapper.deleteById(myReminderId);
        if (del>0){
            return RespResult.success();
        }
        return RespResult.error("取消提醒失败");
    }
}
